extends Talent
var utils = globalData.infoDs["g_AneHekUtils"]
var base = globalData.infoDs["g_AneHekBase"]
func init():
	name = "塔防英雄"

func newChaBt(node, id):
	var chaBt = preload("res://ui/itemBt/itemBt.tscn").instance()
	chaBt.id = id
	node.add_child(chaBt)

func _connect():
	if utils.canhero:
		utils.canhero = false
		base.setData("canhero",false)
		var ui = sys.main.get_node("ui")
		var win  = utils.cWin(ui,"英雄选择",Vector2(1000,600))
		win.popup_exclusive = true
		win.get_close_button().hide()
		var g = GridContainer.new()
		g.set_columns(3)
		g.rect_position = Vector2(275, 75)
		win.add_child(g)
		newChaBt(g,"cex___Hide_SaintSwordsman")
		newChaBt(g,"cex___Hide_SaintRanger")
		newChaBt(g,"cex___Hide_SoulMage")
		utils.cBtns(g,self,"选择","chose",["cex___Hide_SaintSwordsman",win],Vector2(100,50))
		utils.cBtns(g,self,"选择","chose",["cex___Hide_SaintRanger",win],Vector2(100,50))
		utils.cBtns(g,self,"选择","chose",["cex___Hide_SoulMage",win],Vector2(100,50))
		var g2 = GridContainer.new()
		g2.set_columns(3)
		g2.rect_position = Vector2(275, 275)
		win.add_child(g2)
		newChaBt(g2,"cex___Hide_Paladin")
		newChaBt(g2,"cex___Hide_PhantomBlade")
		newChaBt(g2,"cex___Hide_DragonKnight")
		var bt1 = utils.cBtns(g2,self,"选择","chose",["cex___Hide_Paladin",win],Vector2(100,50))
		var bt2 = utils.cBtns(g2,self,"选择","chose",["cex___Hide_PhantomBlade",win],Vector2(100,50))
		var bt3 = utils.cBtns(g2,self,"选择","chose",["cex___Hide_DragonKnight",win],Vector2(100,50))
		var x = base.getData("x1",0) 
		if !x:
			bt1.disabled = true
			bt2.disabled = true
			bt3.disabled = true
		elif x == 1:
			var waitrnd = []
			waitrnd.append(bt1)
			waitrnd.append(bt2)
			waitrnd.append(bt3)
			waitrnd.remove(waitrnd.find(sys.rndListItem(waitrnd)))
			for i in waitrnd:
				i.disabled = true
		utils.cBtns(win,self,"帮助","help",[],Vector2(920,20))
		win.popup_centered()
		
func help():
	sys.newBaseMsg("帮助","使用第一行英雄通关无尽模式（需要选择真·无尽），会解锁第二行随机英雄[每场游戏随机];使用第二行通关无尽模式（需要选择真·无尽），则所有英雄皆可用")

func chose(id,win):
	win.queue_free()
	if base.getData("x1",0) != 2:
		if id == "cex___Hide_SaintSwordsman" || id == "cex___Hide_SaintRanger" || id == "cex___Hide_SoulMage":
			utils.x1 = 1
		else:
			utils.x1 = 2
	else:
		utils.x1 = 2
	sys.main.player.addCha(sys.main.newChara(id))
func get_info():
	return "从所有英雄中选择一个并获得\n此天赋不需要升级"